<?php
/**[用户组控制器]
 * @Author: chenli
 * @Email:  976123967@qq.com
 * @Date:   2015-02-23 11:53:21
 * @Last Modified by:   chenli
 * @Last Modified time: 2015-02-23 22:37:01
 */
class AuthGroupAction extends PublicAction{


	public $logic;
	public function _initialize()
	{
		parent::_initialize();
		$this->logic = D('AuthGroup','Logic');
	}

	/**
	 * [index 用户组列表]
	 * @return [type] [description]
	 */
	public function index()
	{
		$data = $this->logic->find_all();
		$this->assign('data',$data);
		$this->display();
	}

	/**
	 * [add 添加]
	 */
	public function add()
	{
		if(IS_POST)
		{
			if(!$this->logic->add_auth_group())
				$this->error($this->logic->getError());
			$this->success('用户组添加成功',U('AuthGroup/index'));
			die;
		}
		$this->display();
	}

	/**
	 * [edit 编辑]
	 * @return [type] [description]
	 */
	public function edit()
	{
		if(IS_POST)
		{
			if(!$this->logic->edit_auth_group())
				$this->error($this->logic->getError());
			$this->success('用户组编辑成功',U('AuthGroup/index'));
			die;
		}
		$field  = $this->logic->find_one();
		$this->assign('field',$field);
		$this->display();
	}

	/**
	 * [del 删除用户组]
	 * @return [type] [description]
	 */
	public function del()
	{
		if(!$this->logic->del_auth_group())
			$this->error($this->logic->getError());
		$this->success('用户组删除成功',U('AuthGroup/index'));
	}


	public function rule()
	{
		if(IS_POST)
		{
			if(!$this->logic->alter_rule())
				$this->error($this->model->getError());
			$this->success('规则设置成功');
			die;
		}
		$rule = D('AuthRule','Logic')->find_all(1);
		$this->assign('rule',$rule);

		$field  = $this->logic->find_one();
		$this->assign('field',$field);
		$this->display();
	}
}
